${r'<#assign basePath=request.contextPath />'}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

	${r"<#include '/common/common-css.html'>"}
</head>

<body>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="myForm">
                    	<input type="hidden" name="id" id="id" value="">
                    	<#list list as arr>
            			<div class="form-group">
                            <label class="col-sm-3 control-label"><sapn class="text-danger">* </sapn>${arr[2]}：</label>
                            <div class="col-sm-8">
                                <input id="${arr[1]}" name="${arr[1]}" class="form-control" type="text" value="">
                                <span class="help-block m-b-none">
                                </span>
                            </div>
                        </div>
                		</#list>
                    </form>
                </div>
            </div>
        </div>
    </div>
    ${r"<#include '/common/common-js.html'>"}
    <script type="text/javascript">
    $().ready(function() {
    	$("#id").val("${r'${'}${entity?uncap_first}${r'.id}'}");
    	<#list list as arr>
    	$("#${arr[1]}").val("${r'${'}${entity?uncap_first}.${arr[1]}${r'}'}");
    	</#list>
        var e = "<i class='fa fa-times-circle'></i> ";
        $("#myForm").validate({
            rules: {
            	<#list list as arr>
            	${arr[1]}: {
                    required: !0
                },
                </#list>
            },
            messages: {
            	<#list list as arr>
            	${arr[1]}: {
                    required: e + "请输入${arr[2]}"
                },
                </#list>
            },
            submitHandler:function(form){
            	var data = {
            		"id" : $("#id").val(),
            		<#list list as arr>
	            	"${arr[1]}" : $("#${arr[1]}").val(),
	                </#list>
            	};
    			$.ajax({    
    		        type: "post",   
    		        url: "${r'${basePath}'}/${entity?uncap_first}/edit?t=" + Math.random(),   
    		        data : data,
    		        dataType: "json",    
    		        success: function (data) { 
    		        	if(data.error){
    						layer.msg(data.msg,{icon:2,time:1000});
    					}else{
    						if(data == 1){
        		        		parent.table.ajax.reload();
        		            	var index = parent.layer.getFrameIndex(window.name);
        		        		parent.layer.close(index);
        		        		
        		        		parent.layer.msg('修改成功!',{icon:1,time:1000});
        		        	}
    					}
    		        },
    		        error:function(e) {
    					console.log(e);
    				}
    		    }) 
    		}
        }); 
    });
    
    function edit(){
    	$("#myForm").submit();
    }
    </script>
</body>
</html>


    